package com.cn.controller;

import com.cn.entity.User;
import com.cn.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserRepository userRepositoryDls;

    @GetMapping("getUser")
    public User getUser(Integer id){
        return userRepositoryDls.getOne(id);
    }

    @PostMapping("saveUser")
    public User saveUser(User user){
        userRepositoryDls.save(user);
        return user;
    }

}
